@push('title')
    <title>OTA统一政策上传</title>
@endpush
@push('style2')
    <style>
        .layui-form-label {
            width: 100px !important;
            text-align: right !important;
        }

        .layui-form-item .layui-inline-padding {
            width: 78px; padding-right: 4px;
        }

        .ant-form-explain {
            clear: both;
            color: rgba(0, 0, 0, .45);
            font-size: 14px;
            line-height: 1.5;
            margin-top: -2px;
            margin-left: 130px;
            margin-bottom: 2px;
            padding-top: 4px;
            min-height: 22px;
            transition: color .3s cubic-bezier(.215, .61, .355, 1);
        }
        .airlineBank {
            width: 200px !important;
            text-align: left !important;
        }
    </style>
@endpush
@extends('layout.layer')
@section('content')
    <form class="layui-form layui-form-pane1" id="alert-form" action="#" lay-filter="first">
        <input type="hidden" name="_token" value="{{csrf_token()}}">

        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-inline">
                <select name="status" lay-filter="interest">
                    <option value="1" selected>有效</option>
                    <option value="2">无效</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label layui-required">航司编码</label>
            <div class="layui-input-inline">
                <input type="text" id="AirLine" name="hs_code" value="" lay-verify="required|title" maxlength="2" lay-reqText="航司编码" required placeholder="航司编码" autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label layui-required">起飞三字码</label>
            <div class="layui-input-inline">
                <input type="text" name="depart_city_code" value="" lay-verify="required|title" maxlength="3" lay-reqText="起飞三字码" required placeholder="起飞三字码" autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label layui-required">到达三字码</label>
            <div class="layui-input-inline">
                <input type="text" name="arrived_city_code" value="" lay-verify="required" maxlength="3" lay-reqText="到达三字码" required placeholder="到达三字码" autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label layui-required">航班</label>
            <div class="layui-input-inline">
                <input type="text" name="flight_code" value="" lay-verify="required|number" maxlength="4" lay-reqText="航班" required placeholder="航班" autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label layui-required">起飞日期</label>
            <div class="layui-input-inline">
                <input type="date" name="date" value="" lay-verify="required" maxlength="10" lay-reqText="起飞日期" required placeholder="起飞日期" autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label layui-required">销售日期:</label>
            <div class="layui-input-inline" id="sale-date" style="width: 500px;">
                <div class="layui-input-inline layui-input-wrap">
                    <div class="layui-input-prefix">
                        <i class="layui-icon layui-icon-date"></i>
                    </div>
                    <input type="text" name="startSellDate" value="{{date('Y-m-d')}}" autocomplete="off" id="sale-start"
                           lay-verify="required|title" class="layui-input" placeholder="开始日期">
                </div>
                <div class="layui-form-mid">-</div>
                <div class="layui-input-inline  layui-input-wrap">
                    <div class="layui-input-prefix">
                        <i class="layui-icon layui-icon-date"></i>
                    </div>
                    <input type="text" name="endSellDate" value="{{date('Y-m-d',strtotime('+1day'))}}" autocomplete="off" id="sale-end"
                           lay-verify="required|title" class="layui-input" placeholder="结束日期">
                </div>
            </div>
            <div class="ant-form-explain">必填，当天截止销售的政策，24点之后不显示</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label layui-required">政策代码</label>
            <div class="layui-input-inline">
                <input type="text" name="policy_code" value="" lay-verify="required" maxlength="40" lay-reqText="政策代码" required placeholder="政策代码" autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label layui-required">舱位</label>
            <div class="layui-input-inline">
                <input type="text" name="cabin_code" value="" lay-verify="required" maxlength="3" lay-reqText="舱位" required placeholder="舱位" autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">支持共享：</label>
            <div class="layui-input-inline">
                <select name="is_share" lay-filter="interest">
                    <option value="F">否</option>
                    <option value="T">是</option>
                </select>
            </div>
        </div>


        <div class="layui-form-item" id="xc-item" style="display: none">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">携程结算价</label>
                    <div class="layui-input-inline" style="width: 150px;">
                        <input type="text" id="set_price" name="set_price" value="" lay-verify="" placeholder="结算价" maxlength="10" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">携程竞价金额</label>
                    <div class="layui-input-inline" style="width: 150px;">
                        <input type="text" id="cabin_price" name="cabin_price" value="" lay-verify="" placeholder="0" maxlength="10" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid">最大值300</div>
                </div>
            </div>
        </div>

        <div class="layui-form-item" id="gz-item" style="display: none">
            <div class="layui-inline">
                <label class="layui-form-label">规则运价</label>
                <div class="layui-input-inline" style="width: 150px;">
                    <input type="text" id="compare_price" name="compare_price" value="" lay-verify="" placeholder="竞价空间(<=100)" maxlength="10" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid">-</div>
                <div class="layui-input-inline" style="width: 150px;">
                    <input type="text" id="one_dec_price" name="one_dec_price" value="" lay-verify="" placeholder="直减金额" maxlength="10" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item" id="qn-productMarkDiv" style="display: none">
            <label class="layui-form-label layui-required">去哪产品类型:</label>
            <div class="layui-input-inline" id="noAirline" style="width: 405px">
                <div class="layui-form-label airlineBank" style="width: 120px;padding: 9px 0px">请先输入航空公司</div>
            </div>
            <div class="layui-input-inline" id="HaveAirline" style="width: 500px; display: none;" lay-filter="" lay-verify="required" lay-reqText="请选择产品类型">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="500" title="标品 (500)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="222" title="标品-高频人群 (222)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="228" title="标品-复购特惠 (228)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="-1" title="定向套餐 (-1)" checked>
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="201" title="旅行套餐 (201)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="221" title="旅行套餐-高频人群 (221)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="223" title="旅行套餐-高频年龄22-60岁 (223)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="227" title="旅行套餐-复购特惠 (227)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="280" title="机酒套餐 (280)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="894" title="早鸟套餐 (894)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="514" title="年龄特惠3-28岁 (514)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="497" title="年龄特惠12-22岁及55岁以上 (497)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="504" title="年龄特惠13-23岁及55岁以上 (504)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="501" title="年龄特惠18-22岁及55岁以上 (501)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="891" title="青年特惠13-22岁 (891)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="505" title="青年特惠18-22岁 (505)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="431" title="青年特惠18-24岁 (431)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="503" title="年龄特惠16-24岁及50岁以上 (503)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="574" title="老年特惠60-100岁 (574)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="493" title="2-9人小团 (493)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="502" title="3-9人小团 (502)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="266" title="直采产品 (266)">
                <input type="checkbox" name="productMark[]" lay-filter="productMark" value="265" title="直采产品 (265)">
            </div>
            <div class="ant-form-explain">tips：鼠标移入产品可查看产品说明；支持选择多个</div>
        </div>

        <div class="layui-form-item" id="qn-item" style="display: none">
            <div class="layui-inline">
                <label class="layui-form-label">去哪价格</label>
                <div class="layui-input-inline" style="width: 150px;">
                    <input type="text" id="seller_price" name="seller_price" value="" lay-verify="" placeholder="票面价" maxlength="10" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid">-</div>
                <div class="layui-input-inline" style="width: 150px;">
                    <input type="text" id="auto_price_price" name="auto_price_price" value="" lay-verify="" placeholder="阀值" maxlength="10" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item" id="tc-item" style="display: none">
            <div class="layui-inline">
                <label class="layui-form-label">同程固定价格</label>
                <div class="layui-input-inline" style="width: 150px;">
                    <input type="text" id="fix_price" name="fix_price" value="" lay-verify="" placeholder="同程固定价格" maxlength="10" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid">-</div>
                <div class="layui-inline">
                    <input type="text" id="fix_price_biding" name="fix_price_biding" value="" lay-verify="" placeholder="同程竞价空间" maxlength="10" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">库存类型:</label>
            <div class="layui-input-block">
                <input type="radio" name="InventoryType" value="FIX" lay-filter="InventoryType" title="按照库存销售" checked>
                <input type="radio" name="InventoryType" value="FAV" lay-filter="InventoryType" title="在Eterm舱位外放时设置最大销售数量">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label layui-required">座位数</label>
            <div class="layui-input-inline">
                <input type="text" id="seat" name="seat" value="" lay-verify="" maxlength="3" lay-reqText="座位数" required placeholder="座位数" autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label layui-required">上传平台</label>
            <div class="layui-input-block" id="platformDiv" lay-verify="required">
                @if(in_array(10,request()->admin_platform) && in_array(11,request()->admin_platform))
                <input type="checkbox" name="hb" lay-filter="platformName" value="1" title="恒博携程">&nbsp;
                <input type="checkbox" name="mh" lay-filter="platformName" value="2" title="茂华携程">&nbsp;
                @elseif(in_array(10,request()->admin_platform))
                <input type="checkbox" name="hb" lay-filter="platformName" value="2" title="恒博携程">&nbsp;
                @elseif(in_array(11,request()->admin_platform))
                <input type="checkbox" name="mh" lay-filter="platformName" value="2" title="茂华携程">&nbsp;
                @endif

                @if(in_array(20,request()->admin_platform) && in_array(21,request()->admin_platform))
                <input type="checkbox" name="gz" lay-filter="platformName" value="3" title="恒博规则运价">&nbsp;
                <input type="checkbox" name="mhgz" lay-filter="platformName" value="6" title="茂华规则运价">&nbsp;
                @elseif(in_array(20,request()->admin_platform))
                <input type="checkbox" name="gz" lay-filter="platformName" value="3" title="恒博规则运价">&nbsp;
                @elseif(in_array(21,request()->admin_platform))
                <input type="checkbox" name="mhgz" lay-filter="platformName" value="6" title="茂华规则运价">&nbsp;
                @endif
                @if(in_array(30,request()->admin_platform))
                <input type="checkbox" name="qn" lay-filter="platformName" value="4" title="去哪">&nbsp;
                @endif
                @if(in_array(40,request()->admin_platform))
                <input type="checkbox" name="tc" lay-filter="platformName" value="5" title="同城">&nbsp;
                @endif
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
@endsection
@push('script')
    <script src="/static/js/common.js?version={{env('JS_VERSION')}}"></script>
    <script src="/static/js/platform/platformAll.js?version={{env('JS_VERSION')}}"></script>
    <script>
        layui.use(['form','layer'], function() {

            var $ = layui.$
                ,form = layui.form
                ,layer = layui.layer;

            //监听提交
            form.on('submit(*)', function(data){

                // var loading = layer.load(2,{offset: ['40%','50%'],shade: [0.1,'#3595CC'],area: ['10%','10%']});

                $.ajax({
                    url: '/platform/ajaxUpload'
                    , method: 'post'
                    , data: data.field
                    , dataType: 'json'
                    , success: function (data) {

                        layer.msg(data.errmsg, {
                            offset: '25px'
                            ,icon: (data.errcode == 0 ? 1: 5)
                            ,time: 25000
                            ,area:['400px','66px']
                        }, function(){});

                        if (data.errcode == 0) {

                            //$('#alert-form')[0].reset();
                        }

                        // layer.close(loading);
                    },
                });

                return false;
            });
        });
    </script>
@endpush